<template>
  <div>
    <p-table
      size="middle"
      bordered
      rowKey="id"
      :pagination="false"
      :columns="columns"
      :dataSource="dataSource"
      :loading="loading"
    />
  </div>
</template>

<script>
import { postAction } from "@/api/manage";

export default {
  props: {
    processBillNo: String,
  },
  data() {
    return {
      columns: [
        {
          title: "序号",
          dataIndex: "rowIndex",
          width: 50,
          align: "center",
          customRender(text, record, index) {
            return index + 1;
          },
        },
        {
          title: "线体",
          align: "center",
          dataIndex: "lineName",
        },
        {
          title: "工站",
          align: "center",
          dataIndex: "stationName",
        },
        {
          title: "PN/SN",
          align: "center",
          dataIndex: "pnsn",
        },
        {
          title: "产品编码",
          align: "center",
          dataIndex: "productCode",
        },
        // {
        //   title: "产品数量",
        //   align: "center",
        //   dataIndex: "productQty",
        // },
         {
          title: "关键物料编码",
          align: "center",
          dataIndex: "meterialBarCode",
        },
        {
          title: "关键物料描述",
          align: "center",
          dataIndex: "meterialName",
        },
        {
          title: "关键物料条码(旧)",
          align: "center",
          dataIndex: "oldBarCode",
        },
        {
          title: "关键物料条码(新)",
          align: "center",
          dataIndex: "newBarCode",
        },
        {
          title: "替换人员",
          align: "center",
          dataIndex: "exchageUser",
        },
      ],
      dataSource: [],
      loading: false,
    };
  },
  watch: {
    processBillNo() {
      this.getData();
    },
  },
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      this.loading = true;
      let params = {
        keyword: "",
        limit: 10,
        mainId: "",
        pageNo: 1,
      };
      postAction(
        "/mes-manufacture/mfBindingExchageRecord/getKeyMeterialExchangeList",
        params
      ).then((res) => {
        this.loading = false;
        this.dataSource = res.data.records || [];
      });
    },
  },
};
</script>
